<?php

require_once realpath(dirname(__FILE__) . '//..//pages.php');
require_once INC_DEFINES;
require_once INC_FUNCTIONS;

checkSession();
$db = openConnection();
if (!$db) {
    notify('No database available!');
    exit();
} else {
    /* Getting data from POST */
    if (count($_POST)) {
        $_SESSION['data'] = $_POST;
    } else {
        unset($_SESSION['data']);
    }

    /* Rebuilding GET */
    $args = '';
    foreach ($_GET as $key => $value) {
        $args .= "$key=$value&";
    }
    $args = substr($args, 0, strlen($args) - 1);

    if (isset($_GET['msg'])) {
        $msg = $_GET['msg'];
        require_once VW_NOTIFY;
    } else if (isset($_GET['account'])) {
        header('location: ' . HTTP_CTRL_ACCOUNT . '?' . $args);
    } else if (isset($_GET['request'])) {
        header('location: ' . HTTP_CTRL_REQUEST . '?' . $args);
    } else if (isset($_GET['stat'])) {
        header('location: ' . HTTP_CTRL_STAT . '?' . $args);
    }
}
?>
